package com.xunshibao.core.security;

import javax.servlet.http.HttpSession;

import com.xunshibao.core.web.SessionUser;

public class SecurityUtils {
	public static final String USER_KEY = "user";
	public static boolean saveUserToSession(HttpSession session,
			SessionUser user) {
		if(session != null) {
			session.setAttribute(USER_KEY, user);
			return true;
		} else {
			return false;
		}
	}
	
	public static SessionUser getUserFromSession(HttpSession session) {
		if(session != null) {
			return (SessionUser) session.getAttribute(USER_KEY);
		} else {
			return null;
		}
	}
}
